import request from '@/axios'
import type { EquipmentType, Equipment } from './types'

interface EquipmentTypePageParams {
  pageNo: number
  pageSize: number
  equipmentTypeName: string
}

interface EquipmentPageParams {
  pageNo: number
  pageSize: number
  name: string
  equipmentTypeId: number
  brand: string
  model: string
}

export const equipmentTypeListApi = (
  params: EquipmentTypePageParams
): Promise<IResponse<string[]>> => {
  return request.post({ url: '/api/equipmentType/list', params })
}

export const equipmentTypeListAllApi = (): Promise<IResponse<string[]>> => {
  return request.post({ url: '/api/equipmentType/listAll' })
}

export const equipmentTypeInsertApi = (data: Partial<EquipmentType>): Promise<IResponse> => {
  return request.post({ url: '/api/equipmentType/insert', data })
}

export const equipmentTypeUpdateApi = (data: Partial<EquipmentType>): Promise<IResponse> => {
  return request.post({ url: '/api/equipmentType/update', data })
}

export const equipmentListApi = (params: EquipmentPageParams): Promise<IResponse<string[]>> => {
  return request.post({ url: '/api/equipment/list', params })
}

export const equipmentInsertApi = (data: Partial<Equipment>): Promise<IResponse> => {
  return request.post({ url: '/api/equipment/insert', data })
}

export const equipmentUpdateApi = (data: Partial<Equipment>): Promise<IResponse> => {
  return request.post({ url: '/api/equipment/update', data })
}

export const equipmentDeleteApi = (data: any): Promise<IResponse> => {
  return request.post({ url: '/api/equipment/delete', data })
}
